package team.yidong.fenda.wx.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import redis.clients.jedis.Jedis;
import team.yidong.fenda.entity.Answer;
import team.yidong.fenda.entity.Master;
import team.yidong.fenda.entity.Question;
import team.yidong.fenda.wx.Service.WxAnswerService;
import team.yidong.fenda.wx.Service.WxMasterService;
import team.yidong.fenda.wx.Service.WxQuestionService;

import java.text.ParseException;

/**
 * Created by xuanlong on 2017/11/10.
 */
@Controller
public class WxAnswerController {
    @Autowired
    WxAnswerService wxAnswerService;


    @RequestMapping("/wx/addAnswer")
    @ResponseBody
    public void addAnswer(@RequestParam Integer questionId, @RequestParam String wxNumber, String info, String recordUrl, String imgUrl, @RequestParam String getDate, String recordTime, String answerTime) throws ParseException {
        Jedis jedis = new Jedis("localhost");
        wxNumber = jedis.get(wxNumber);
        System.out.println(imgUrl);
        wxAnswerService.addAnswer(questionId, wxNumber, info, recordUrl, imgUrl, getDate, recordTime, answerTime);
    }

    @RequestMapping("/wx/starAnswer")
    @ResponseBody
    public void starAnswer(@RequestParam Integer answerId) {
        wxAnswerService.starAnswer(answerId);

    }
}
